import 'dart:math';

import 'RectF.dart';

class Equtil {
  static double FREQUENCY_MAX = 20000.0;
static double FREQUENCY_MIN = 20.0;

static double F = 48000.0;//EZDSP
//static double F = 96000.0;//BTDSP
static double R = 6.283185307179586;

static double log10(num x) => log(x) / ln10;

  static cal_rect(RectF rectBounds, int left, int gain, int frency, int width,int height, int right ,int top, int maxDb)
{
    width = fc2int(width,0,frency);
    height = ((1.0 - gain / maxDb) *  height / 2.0).toInt();
    rectBounds.left = (width + right - left).toDouble();
    rectBounds.top = (height - left + top).toDouble();
    rectBounds.right = rectBounds.left +  (left * 2).toDouble();
    rectBounds.bottom = rectBounds.top + (left * 2).toDouble();
}

static int fc2int(int width,int left,int frency)
{
    return ((log10(frency) - log10(20.0)) / (log10(22000.0) - log10(20.0)) * (width - left) + left.toDouble()).toInt();
}

static void cal_point_peq(double q, double gain, int frency,List<double> eqValue)
{
    int length = eqValue.length;
    double var5 = pow(10.0, (gain / 40.0)) as double;
    double var9 = R *  frency / F;
    double var7 = sin(var9) /  (2.0 * q);
    double var11;
    double var13;
    double var15;
    double var17;
    double var19;
    double var21;
    double var23;
    double var25;
    double var27;
    double var29;
    double var31;
    double var33;
    double var35;
    double var37;
    var11 = var7 / var5;
    var15 = -2.0 * cos(var9);
    var13 = 1.0 - var7 / var5;
    var27 = -(2.0 * cos(var9)) * 1.0;
    var19 = (1.0 - var7 * var5) * 1.0;
    
    for (int i = 0; i < length; ++i) {
        var37 = R * int2fc2(length ,0 ,i) / F;
        var33 = cos(var37);
        var25 = cos(2.0 * var37);
        var31 = -var27;
        var21 = sin(var37);
        var35 = sin(2.0 * var37);
        var23 = cos(var37);
        var29 = cos(2.0 * var37);
        var17 = -var15;
        var9 = sin(var37);
        var37 = sin(2.0 * var37);
        eqValue[i] = (log10(sqrt((pow(var33 * var27 + (1.0 + var7 * var5) * 1.0 + var25 * var19, 2.0) + pow(var31 * var21 - var35 * var19, 2.0)) / (pow(var23 * var15 + 1.0 + var11 + var29 * var13, 2.0) + pow(var17 * var9 - var37 * var13, 2.0)))));
    }
}


static List<double> createArray(int count)
{
    List<double> arr = [];
    for (int i = 0; i<count; i++) {
        arr.add(0);
    }
    return arr;
}

static void mk(double f, List<double> a, List<double> b,List<double> one,int length,bool ispol)
{
    int len = length;
    double x, w, u, v, s, t, h;
    
    if (ispol)
    {
        for (int i = 0; i < len; i++)
        {
            x =
            pow(10, (i - 0)/ (len - 0) * (log10(20000) -log10(20.0)) + log10(20.0)) as double;
            
            
            w = 2 * pi * x / 48000;
            
            
            u = (b[0] + b[1] * cos(w) + b[2] *cos(2 * w));
            v = (-b[1] * sin(w) - b[2] * sin(2 * w));
            s = (a[0] + a[1] * cos(w) + a[2] * cos(2 * w));
            t = (-a[1] * sin(w) - a[2] * sin(2 * w));
            
            double Im = (s * v - t * u);
            double Re = (s * u + t * v);
            
            h = 180 * atan2(Im, Re) / pi;
            
            one[i] = h;
        }
    }
    else
    {
        for (int i = 0; i < len; i++)
        {
            x = pow(10, (i - 0).toDouble() * (log10(20000) -log10(20.0))/ (len - 0) + log10(20.0)) as double;
            w = 2 * pi * x /48000.0;
            
            u = (b[0] + b[1] * cos(w) + b[2] * cos(2 * w));
            v = (-b[1] * sin(w) - b[2] * sin(2 * w));
            s = (a[0] + a[1] * cos(w) + a[2] *cos(2 * w));
            t = (-a[1] * sin(w) - a[2] * sin(2 * w));
            
            h = sqrt((pow(u, 2) + pow(v, 2)) / (pow(s, 2) + pow(t, 2)));
            
            one[i] = (log10(h));
        }
    }
}

static void cal_point_xover(int index,double f,int oct_type,int oct_db,bool ishpass,int line_xover_length,List<double> line_xover)
{
    double pow10 = 10000000000;
//    double* p = new double[4];
//    double* a0 = new double[3], *b0 = new double[3];
//    double* a1 = new double[3], *b1 = new double[3];
//    double* a2 = new double[3], *b2 = new double[3];
//    double* a3 = new double[3], *b3 = new double[3];
//    double* one_0=0, *one_1=0, *one_2=0,*one_3=0;
    List<double> p = createArray(4);
    List<double> a0 = createArray(3);
    List<double> a1 = createArray(3);
    List<double> a2 = createArray(3);
    List<double> a3 = createArray(3);
    List<double> b0 = createArray(3);
    List<double> b1 = createArray(3);
    List<double> b2 = createArray(3);
    List<double> b3 = createArray(3);
    List<double> one_0 = [];
    List<double> one_1 = [];
    List<double> one_2 = [];
    List<double> one_3 = [];


    
    double w0 = 2 * pi * f /48000;
    double oc = 2 * tan(w0 / 2);
    double c1 = oc * tan(w0 / 2);
    
    
    
    if(!ishpass)// 是不是高通
    {
        switch(oct_type)  //
        {
            case 0://BW-06
            {
                
                {
                    
                    
                    a0[0] = 1;
                    a0[1] = ((oc - 2) / (2 + oc));
                    a0[2] = 0;
                    b0[0] = (oc / (2 + oc));
                    b0[1] = b0[0];
                    b0[2] = 0;
//                    one_0 = new double[line_xover_length];
                    one_0 = createArray(line_xover_length);
//                    mk(f, a0, b0,one_0,line_xover_length, false);
                    mk(f ,a0 ,b0,one_0,line_xover_length,false);
                    for (int i = 0; i < line_xover_length; i++)
                    {
                        line_xover[i] =one_0[i];
                    }
                    
                    
                    
                    if(f==FREQUENCY_MAX)
                    {
                        for (int i = 0; i < line_xover_length; i++)
                        {
                            // line_xover[i] =((line_xover[i] * pow10))/ pow10;
                            line_xover[i] = 0;
                        }
                    }
                    
                    
                }
            }
                break;
            case 1:// BW-12
            {
                
                {
                    
                    p[0] = 1.41421356237309;
                    
                    b0[0] = (oc * oc / (4 + 2 * p[0] * oc + oc * oc));
                    b0[1] = (2 * b0[0]);
                    b0[2] = b0[0];
                    a0[0] = 1;
                    a0[1] = (2 * (oc * oc - 4) / (4 + 2 * p[0] * oc + oc * oc));
                    a0[2] = ((4 - 2 * p[0] * oc + oc * oc) / (4 + 2 * p[0] * oc + oc * oc));
//                    one_0 = new double[line_xover_length];
                    one_0 = createArray(line_xover_length);
//                    mk(f, a0, b0,  one_0,line_xover_length, false);
                    mk(f, a0, b0,one_0,line_xover_length,false);
                    
                    for (int i=0;i<line_xover_length;i++)
                    {
                        line_xover[i]=one_0[i];
                    }
                    
                    
                    if(f==FREQUENCY_MAX)
                    {
                        for (int i = 0; i < line_xover_length; i++)
                        {
                            // line_xover[i] =((line_xover[i] * pow10))/ pow10;
                            line_xover[i] =0;
                        }
                    }
                }
                
            }
                break;
            case 2:  //BW-18
            {
                p[0] = 1;
                p[1] = 1;
                
                b0[0] = (oc * oc / (4 + 2 * p[0] * oc + oc * oc));
                b0[1] = (2 * b0[0]);
                b0[2] = b0[0];
                a0[0] = 1;
                a0[1] = (2 * (oc * oc - 4) / (4 + 2 * p[0] * oc + oc * oc));
                a0[2] = ((4 - 2 * p[0] * oc + oc * oc) / (4 + 2 * p[0] * oc + oc * oc));
                
                b1[0] = (p[1] * oc / (2 + p[1] * oc));
                b1[1] = b1[0];
                b1[2] = 0;
                a1[0] = 1;
                a1[1] = ((p[1] * oc - 2) / (2 + p[1] * oc));
                a1[2] = 0;
                
//                one_0 = new double[line_xover_length];
//                one_1 = new double[line_xover_length];
                one_0 = createArray(line_xover_length);
                one_1 = createArray(line_xover_length);
                
//                mk(f, a0, b0,  one_0, line_xover_length, false);
//                mk(f, a1, b1,  one_1, line_xover_length, false);
                mk(f, a0,b0,one_0,line_xover_length,false);
                mk(f,a1,b1,one_1,line_xover_length,false);
                
                for (int i = 0; i < line_xover_length; i++)
                {
                    line_xover[i] = ((one_0[i] + one_1[i]));
                }
                
                if(f==FREQUENCY_MAX)
                {
                    for (int i = 0; i < line_xover_length; i++)
                    {
                        // line_xover[i] =((line_xover[i] * pow10))/ pow10;
                        line_xover[i] =0;
                    }
                }
                
                
            }
                break;
            case 3: //BW-24
            {
                p[0] = 0.76536686473018;
                p[1] = 1.84775906502257;
                
                b0[0] = (oc * oc / (4 + 2 * p[0] * oc + oc * oc));
                b0[1] = (2 * b0[0]);
                b0[2] = b0[0];
                a0[0] = 1;
                a0[1] = (2 * (oc * oc - 4) / (4 + 2 * p[0] * oc + oc * oc));
                a0[2] = ((4 - 2 * p[0] * oc + oc * oc) / (4 + 2 * p[0] * oc + oc * oc));
                
                
                b1[0] = (oc * oc / (4 + 2 * p[1] * oc + oc * oc));
                b1[1] = (2 * b1[0]);
                b1[2] = b1[0];
                a1[0] = 1;
                a1[1] = (2 * (oc * oc - 4) / (4 + 2 * p[1] * oc + oc * oc));
                a1[2] = ((4 - 2 * p[1] * oc + oc * oc) / (4 + 2 * p[1] * oc + oc * oc));
                
//                one_0 = new double[line_xover_length];
//                one_1 = new double[line_xover_length];
//
//                mk(f, a0, b0,  one_0, line_xover_length, false);
//                mk(f, a1, b1,  one_1, line_xover_length, false);
                one_0 = createArray(line_xover_length);
                one_1 = createArray(line_xover_length);
                
                mk(f, a0,b0,one_0,line_xover_length,false);
                mk(f,a1,b1,one_1,line_xover_length,false);

                
                for (int i = 0; i < line_xover_length; i++)
                {
                    line_xover[i] = (one_0[i] + one_1[i]);
                }
                
                if(f.toInt()==FREQUENCY_MAX)
                {
                    for (int i = 0; i < line_xover_length; i++)
                    {
                        // line_xover[i] =((line_xover[i] * pow10))/ pow10;
                        line_xover[i] =0;
                    }
                }
                
            }
                break;
            case 4: //BW_36
            {
                p[0] = 0.51763809020504;
                p[1] = 1.41421356237309;
                p[2] = 1.93185165257814;
                
                b0[0] = (oc * oc / (4 + 2 * p[0] * oc + oc * oc));
                b0[1] = (2 * b0[0]);
                b0[2] = b0[0];
                a0[0] = 1;
                a0[1] = (2 * (oc * oc - 4) / (4 + 2 * p[0] * oc + oc * oc));
                a0[2] = ((4 - 2 * p[0] * oc + oc * oc) / (4 + 2 * p[0] * oc + oc * oc));
                
                b1[0] = (oc * oc / (4 + 2 * p[1] * oc + oc * oc));
                b1[1] = (2 * b1[0]);
                b1[2] = b1[0];
                a1[0] = 1;
                a1[1] = (2 * (oc * oc - 4) / (4 + 2 * p[1] * oc + oc * oc));
                a1[2] = ((4 - 2 * p[1] * oc + oc * oc) / (4 + 2 * p[1] * oc + oc * oc));
                
                b2[0] = (oc * oc / (4 + 2 * p[2] * oc + oc * oc));
                b2[1] = (2 * b2[0]);
                b2[2] = b2[0];
                a2[0] = 1;
                a2[1] = (2 * (oc * oc - 4) / (4 + 2 * p[2] * oc + oc * oc));
                a2[2] = ((4 - 2 * p[2] * oc + oc * oc) / (4 + 2 * p[2] * oc + oc * oc));
                
//                one_0 = new double[line_xover_length];
//                one_1 = new double[line_xover_length];
//                one_2 = new double[line_xover_length];
//
//                mk(f, a0, b0,  one_0, line_xover_length, false);
//                mk(f, a1, b1,  one_1, line_xover_length, false);
//                mk(f, a2, b2,  one_2, line_xover_length, false);
                one_0 = createArray(line_xover_length);
                one_1 = createArray(line_xover_length);
                one_2 = createArray(line_xover_length);
                
                mk(f, a0,b0,one_0,line_xover_length,false);
                mk(f,a1,b1,one_1,line_xover_length,false);
                mk(f,a2,b2,one_2,line_xover_length,false);
                
                for (int i = 0; i < line_xover_length; i++)
                {
                    line_xover[i] = (one_0[i] + one_1[i] + one_2[i]);
                }
                
                if(f==FREQUENCY_MAX)
                {
                    for (int i = 0; i < line_xover_length; i++)
                    {
                        // line_xover[i] =((line_xover[i] * pow10))/ pow10;
                        line_xover[i] =0;
                    }
                }
            }
                break;
            case 5:  //BW-48
            {
                p[0] = 0.39018064403226;
                p[1] = 1.11114046603920;
                p[2] = 1.66293922460509;
                p[3] = 1.96157056080646;
                
                b0[0] = (oc * oc / (4 + 2 * p[0] * oc + oc * oc));
                b0[1] = (2 * b0[0]);
                b0[2] = b0[0];
                a0[0] = 1;
                a0[1] = (2 * (oc * oc - 4) / (4 + 2 * p[0] * oc + oc * oc));
                a0[2] = ((4 - 2 * p[0] * oc + oc * oc) / (4 + 2 * p[0] * oc + oc * oc));
                
                b1[0] = (oc * oc / (4 + 2 * p[1] * oc + oc * oc));
                b1[1] = (2 * b1[0]);
                b1[2] = b1[0];
                a1[0] = 1;
                a1[1] = (2 * (oc * oc - 4) / (4 + 2 * p[1] * oc + oc * oc));
                a1[2] = ((4 - 2 * p[1] * oc + oc * oc) / (4 + 2 * p[1] * oc + oc * oc));
                
                b2[0] = (oc * oc / (4 + 2 * p[2] * oc + oc * oc));
                b2[1] = (2 * b2[0]);
                b2[2] = b2[0];
                a2[0] = 1;
                a2[1] = (2 * (oc * oc - 4) / (4 + 2 * p[2] * oc + oc * oc));
                a2[2] = ((4 - 2 * p[2] * oc + oc * oc) / (4 + 2 * p[2] * oc + oc * oc));
                
//                one_0 = new double[line_xover_length];
//                one_1 = new double[line_xover_length];
//                one_2 = new double[line_xover_length];
//                one_3 = new double[line_xover_length];
//
//                mk(f, a0, b0,  one_0, line_xover_length, false);
//                mk(f, a1, b1,  one_1, line_xover_length, false);
//                mk(f, a2, b2,  one_2, line_xover_length, false);
//                mk(f, a3, b3,  one_3, line_xover_length, false);
                
                one_0 = createArray(line_xover_length);
                one_1 = createArray(line_xover_length);
                one_2 = createArray(line_xover_length);
                one_3 = createArray(line_xover_length);
                
                mk(f, a0,b0,one_0,line_xover_length,false);
                mk(f,a1,b1,one_1,line_xover_length,false);
                mk(f,a2,b2,one_2,line_xover_length,false);
                mk(f,a3,b3,one_3,line_xover_length,false);
                
                for (int i = 0; i < line_xover_length; i++)
                {
                    line_xover[i] = (one_0[i] + one_1[i] + one_2[i] + one_3[i]);
                }
                
                if(f==FREQUENCY_MAX)
                {
                    for (int i = 0; i < line_xover_length; i++)
                    {
                        // line_xover[i] =((line_xover[i] * pow10))/ pow10;
                        line_xover[i] =0;
                    }
                }
                
                
            }
                break;
            case 6://BS-12
            {
                p[0] = 1.73205080756888;
                
                b0[0] = (oc * oc / (4 + 2 * p[0] * oc + oc * oc));
                b0[1] = (2 * b0[0]);
                b0[2] = b0[0];
                a0[0] = 1;
                a0[1] = (2 * (oc * oc - 4) / (4 + 2 * p[0] * oc + oc * oc));
                a0[2] = ((4 - 2 * p[0] * oc + oc * oc) / (4 + 2 * p[0] * oc + oc * oc));
                
                
//                one_0 = new double[line_xover_length];
//                mk(f, a0, b0,  one_0, line_xover_length, false);
                one_0 = createArray(line_xover_length);
                mk(f, a0,b0,one_0,line_xover_length,false);
                
                for (int i=0;i<line_xover_length;i++)
                {
                    line_xover[i]=one_0[i];
                }
                
                
                if(f==FREQUENCY_MAX)
                {
                    for (int i = 0; i < line_xover_length; i++)
                    {
                        // line_xover[i] =((line_xover[i] * pow10))/ pow10;
                        line_xover[i] =0;
                    }
                }
                
                
            }
                break;
            case 7://BS-18
            {
                p[0] = 1.49128077169616;
                p[1] = 0.94160002653321;
                
                b0[0] = (oc * oc / (4 + 2 * p[0] * oc + oc * oc));
                b0[1] = (2 * b0[0]);
                b0[2] = b0[0];
                a0[0] = 1;
                a0[1] = (2 * (oc * oc - 4) / (4 + 2 * p[0] * oc + oc * oc));
                a0[2] = ((4 - 2 * p[0] * oc + oc * oc) / (4 + 2 * p[0] * oc + oc * oc));
                
                b1[0] = (p[1] * oc / (2 + p[1] * oc));
                b1[1] = b1[0];
                b1[2] = 0;
                a1[0] = 1;
                a1[1] = ((p[1] * oc - 2) / (2 + p[1] * oc));
                a1[2] = 0;
                
                
//                one_0 = new double[line_xover_length];
//                one_1 = new double[line_xover_length];
//
//                mk(f, a0, b0,  one_0, line_xover_length, false);
//                mk(f, a1, b1,  one_1, line_xover_length, false);
                one_0 = createArray(line_xover_length);
                one_1 = createArray(line_xover_length);
                mk(f, a0,b0,one_0,line_xover_length,false);
                mk(f,a1,b1,one_1,line_xover_length,false);
                
                for (int i = 0; i < line_xover_length; i++)
                {
                    line_xover[i] = (one_0[i] + one_1[i]);
                }
                
                if(f==FREQUENCY_MAX)
                {
                    for (int i = 0; i < line_xover_length; i++)
                    {
                        // line_xover[i] =((line_xover[i] * pow10))/ pow10;
                        line_xover[i] =0;
                        //TRACE(_T("sdsfdfsd\r\n"));
                        
                    }
                }
                
            }
                break;
            case 8://BS-24
            {
                p[0] = 1.31442234334377;
                p[1] = 1.80951759357649;
                
                b0[0] = (oc * oc / (4 + 2 * p[0] * oc + oc * oc));
                b0[1] = (2 * b0[0]);
                b0[2] = b0[0];
                a0[0] = 1;
                a0[1] = (2 * (oc * oc - 4) / (4 + 2 * p[0] * oc + oc * oc));
                a0[2] = ((4 - 2 * p[0] * oc + oc * oc) / (4 + 2 * p[0] * oc + oc * oc));
                
                b1[0] = (oc * oc / (4 + 2 * p[1] * oc + oc * oc));
                b1[1] = (2 * b1[0]);
                b1[2] = b1[0];
                a1[0] = 1;
                a1[1] = (2 * (oc * oc - 4) / (4 + 2 * p[1] * oc + oc * oc));
                a1[2] = ((4 - 2 * p[1] * oc + oc * oc) / (4 + 2 * p[1] * oc + oc * oc));
                
                
//                one_0 = new double[line_xover_length];
//                one_1 = new double[line_xover_length];
//
//                mk(f, a0, b0,  one_0, line_xover_length, false);
//                mk(f, a1, b1,  one_1, line_xover_length, false);
                one_0 = createArray(line_xover_length);
                one_1 = createArray(line_xover_length);
                mk(f, a0,b0,one_0,line_xover_length,false);
                mk(f,a1,b1,one_1,line_xover_length,false);

                
                for (int i = 0; i < line_xover_length; i++)
                {
                    line_xover[i] = (one_0[i] + one_1[i]);
                }
                
                if(f==FREQUENCY_MAX)
                {
                    for (int i = 0; i < line_xover_length; i++)
                    {
                        // line_xover[i] =((line_xover[i] * pow10))/ pow10;
                        line_xover[i] =0;
                    }
                }
                
            }
                break;
            case 9://BS-36
            {
                p[0] = 1.81878136609445;
                p[1] = 1.59930837166566;
                p[2] = 1.07710536333862;
                
                b0[0] = (oc * oc / (4 + 2 * p[0] * oc + oc * oc));
                b0[1] = (2 * b0[0]);
                b0[2] = b0[0];
                a0[0] = 1;
                a0[1] = (2 * (oc * oc - 4) / (4 + 2 * p[0] * oc + oc * oc));
                a0[2] = ((4 - 2 * p[0] * oc + oc * oc) / (4 + 2 * p[0] * oc + oc * oc));
                
                b1[0] = (oc * oc / (4 + 2 * p[1] * oc + oc * oc));
                b1[1] = (2 * b1[0]);
                b1[2] = b1[0];
                a1[0] = 1;
                a1[1] = (2 * (oc * oc - 4) / (4 + 2 * p[1] * oc + oc * oc));
                a1[2] = ((4 - 2 * p[1] * oc + oc * oc) / (4 + 2 * p[1] * oc + oc * oc));
                
                b2[0] = (oc * oc / (4 + 2 * p[2] * oc + oc * oc));
                b2[1] = (2 * b2[0]);
                b2[2] = b2[0];
                a2[0] = 1;
                a2[1] = (2 * (oc * oc - 4) / (4 + 2 * p[2] * oc + oc * oc));
                a2[2] = ((4 - 2 * p[2] * oc + oc * oc) / (4 + 2 * p[2] * oc + oc * oc));
                
//                one_0 = new double[line_xover_length];
//                one_1 = new double[line_xover_length];
//                one_2 = new double[line_xover_length];
//
//
//                mk(f, a0, b0,  one_0, line_xover_length, false);
//                mk(f, a1, b1,  one_1, line_xover_length, false);
//                mk(f, a2, b2,  one_2, line_xover_length, false);
                
                one_0 = createArray(line_xover_length);
                one_1 = createArray(line_xover_length);
                one_2 = createArray(line_xover_length);
                mk(f, a0,b0,one_0,line_xover_length,false);
                mk(f,a1,b1,one_1,line_xover_length,false);
                mk(f,a2,b2,one_2,line_xover_length,false);
                
                
                for (int i = 0; i < line_xover_length; i++)
                {
                    line_xover[i] = (one_0[i] + one_1[i]+one_2[i]);
                }
                
                if(f==FREQUENCY_MAX)
                {
                    for (int i = 0; i < line_xover_length; i++)
                    {
                        // line_xover[i] =((line_xover[i] * pow10))/ pow10;
                        line_xover[i] =0;
                    }
                }
                
                
            }
                
                break;
            case 10: //BS-48
            {
                p[0] = 1.81936630933058;
                p[1] = 1.69465016047187;
                p[2] = 1.42227636169708;
                p[3] = 0.92434808250642;
                
                b0[0] = (oc * oc / (4 + 2 * p[0] * oc + oc * oc));
                b0[1] = (2 * b0[0]);
                b0[2] = b0[0];
                a0[0] = 1;
                a0[1] = (2 * (oc * oc - 4) / (4 + 2 * p[0] * oc + oc * oc));
                a0[2] = ((4 - 2 * p[0] * oc + oc * oc) / (4 + 2 * p[0] * oc + oc * oc));
                
                b1[0] = (oc * oc / (4 + 2 * p[1] * oc + oc * oc));
                b1[1] = (2 * b1[0]);
                b1[2] = b1[0];
                a1[0] = 1;
                a1[1] = (2 * (oc * oc - 4) / (4 + 2 * p[1] * oc + oc * oc));
                a1[2] = ((4 - 2 * p[1] * oc + oc * oc) / (4 + 2 * p[1] * oc + oc * oc));
                
                b2[0] = (oc * oc / (4 + 2 * p[2] * oc + oc * oc));
                b2[1] = (2 * b2[0]);
                b2[2] = b2[0];
                a2[0] = 1;
                a2[1] = (2 * (oc * oc - 4) / (4 + 2 * p[2] * oc + oc * oc));
                a2[2] = ((4 - 2 * p[2] * oc + oc * oc) / (4 + 2 * p[2] * oc + oc * oc));
                
                b3[0] = (oc * oc / (4 + 2 * p[3] * oc + oc * oc));
                b3[1] = (2 * b3[0]);
                b3[2] = b3[0];
                a3[0] = 1;
                a3[1] = (2 * (oc * oc - 4) / (4 + 2 * p[3] * oc + oc * oc));
                a3[2] = ((4 - 2 * p[3] * oc + oc * oc) / (4 + 2 * p[3] * oc + oc * oc));
                
                
//                one_0 = new double[line_xover_length];
//                one_1 = new double[line_xover_length];
//                one_2 = new double[line_xover_length];
//                one_3 = new double[line_xover_length];
//                mk(f, a0, b0,  one_0, line_xover_length, false);
//                mk(f, a1, b1,  one_1, line_xover_length, false);
//                mk(f, a2, b2,  one_2, line_xover_length, false);
//                mk(f, a3, b3,  one_3, line_xover_length, false);
                one_0 = createArray(line_xover_length);
                one_1 = createArray(line_xover_length);
                one_2 = createArray(line_xover_length);
                one_3 = createArray(line_xover_length);
                mk(f, a0,b0,one_0,line_xover_length,false);
                mk(f,a1,b1,one_1,line_xover_length,false);
                mk(f,a2,b2,one_2,line_xover_length,false);
                mk(f,a3,b3,one_3,line_xover_length,false);
                

                
                for (int i = 0; i < line_xover_length; i++)
                {
                    line_xover[i] = (one_0[i] + one_1[i]+one_2[i]);
                }
                
                if(f==FREQUENCY_MAX)
                {
                    for (int i = 0; i < line_xover_length; i++)
                    {
                        // line_xover[i] =((line_xover[i] * pow10))/ pow10;
                        line_xover[i] =0;
                    }
                }
                
                
            }
                break;
            case 11://LK-12
            {
                b0[0] = (oc / (2 + oc));
                b0[1] = b0[0];
                b0[2] = 0;
                a0[0] = 1;
                a0[1] = ((oc - 2) / (2 + oc));
                a0[2] = 0;
                
                b1[0] = b0[0];
                b1[1] = b0[1];
                b1[2] = b0[2];
                a1[0] = a0[0];
                a1[1] = a0[1];
                a1[2] = a0[2];
                
//                one_0 = new double[line_xover_length];
//                one_1 = new double[line_xover_length];
//
//
//                mk(f, a0, b0,  one_0, line_xover_length, false);
//                mk(f, a1, b1,  one_1, line_xover_length, false);
                one_0 = createArray(line_xover_length);
                one_1 = createArray(line_xover_length);
                mk(f, a0,b0,one_0,line_xover_length,false);
                mk(f,a1,b1,one_1,line_xover_length,false);

                
                for (int i=0;i<line_xover_length;i++)
                {
                    line_xover[i]=(one_0[i]+one_1[i]);
                }
                
                
                if(f==FREQUENCY_MAX)
                {
                    for (int i = 0; i < line_xover_length; i++)
                    {
                        // line_xover[i] =((line_xover[i] * pow10))/ pow10;
                        line_xover[i] =0;
                    }
                }
                
            }
                break;
            case 12://LK-24
            {
                p[0] = 1.41421356237309;
                
                b0[0] = (oc * oc / (4 + 2 * p[0] * oc + oc * oc));
                b0[1] = (2 * b0[0]);
                b0[2] = b0[0];
                a0[0] = 1;
                a0[1] = (2 * (oc * oc - 4) / (4 + 2 * p[0] * oc + oc * oc));
                a0[2] = ((4 - 2 * p[0] * oc + oc * oc) / (4 + 2 * p[0] * oc + oc * oc));
                
                b1[0] = b0[0];
                b1[1] = b0[1];
                b1[2] = b0[2];
                a1[0] = a0[0];
                a1[1] = a0[1];
                a1[2] = a0[2];
                
                
//                one_0 = new double[line_xover_length];
//                one_1 = new double[line_xover_length];
//
//
//                mk(f, a0, b0,  one_0, line_xover_length, false);
//                mk(f, a1, b1,  one_1, line_xover_length, false);
                one_0 = createArray(line_xover_length);
                one_1 = createArray(line_xover_length);
                mk(f, a0,b0,one_0,line_xover_length,false);
                mk(f,a1,b1,one_1,line_xover_length,false);

                
                for (int i=0;i<line_xover_length;i++)
                {
                    line_xover[i]=(one_0[i]+one_1[i]);
                }
                
                
                if(f==FREQUENCY_MAX)
                {
                    for (int i = 0; i < line_xover_length; i++)
                    {
                        // line_xover[i] =((line_xover[i] * pow10))/ pow10;
                        line_xover[i] =0;
                    }
                }
            }
                break;
            case 13://LK-36
            {
                p[0] = 0.76536686473018;
                p[1] = 1.84775906502257;
                p[2] = 1.41421356237309;
                
                b0[0] = (oc * oc / (4 + 2 * p[0] * oc + oc * oc));
                b0[1] = (2 * b0[0]);
                b0[2] = b0[0];
                a0[0] = 1;
                a0[1] = (2 * (oc * oc - 4) / (4 + 2 * p[0] * oc + oc * oc));
                a0[2] = ((4 - 2 * p[0] * oc + oc * oc) / (4 + 2 * p[0] * oc + oc * oc));
                
                b1[0] = (oc * oc / (4 + 2 * p[1] * oc + oc * oc));
                b1[1] = (2 * b1[0]);
                b1[2] = b1[0];
                a1[0] = 1;
                a1[1] = (2 * (oc * oc - 4) / (4 + 2 * p[1] * oc + oc * oc));
                a1[2] = ((4 - 2 * p[1] * oc + oc * oc) / (4 + 2 * p[1] * oc + oc * oc));
                
                b2[0] = (oc * oc / (4 + 2 * p[2] * oc + oc * oc));
                b2[1] = (2 * b2[0]);
                b2[2] = b2[0];
                a2[0] = 1;
                a2[1] = (2 * (oc * oc - 4) / (4 + 2 * p[2] * oc + oc * oc));
                a2[2] = ((4 - 2 * p[2] * oc + oc * oc) / (4 + 2 * p[2] * oc + oc * oc));
                
//                one_0 = new double[line_xover_length];
//                one_1 = new double[line_xover_length];
//                one_2 = new double[line_xover_length];
//
//                mk(f, a0, b0,  one_0, line_xover_length, false);
//                mk(f, a1, b1,  one_1, line_xover_length, false);
//                mk(f, a2, b2,  one_2, line_xover_length, false);
                one_0 = createArray(line_xover_length);
                one_1 = createArray(line_xover_length);
                one_2 = createArray(line_xover_length);
                mk(f, a0,b0,one_0,line_xover_length,false);
                mk(f,a1,b1,one_1,line_xover_length,false);
                mk(f,a2,b2,one_2,line_xover_length,false);
                
                for (int i=0;i<line_xover_length;i++)
                {
                    line_xover[i]=(one_0[i]+one_1[i]+one_2[i]);
                }
                
                
                if(f==FREQUENCY_MAX)
                {
                    for (int i = 0; i < line_xover_length; i++)
                    {
                        // line_xover[i] =((line_xover[i] * pow10))/ pow10;
                        line_xover[i] =0;
                    }
                }
                
            }
                break;
            case 14://LK-48
            {
                p[0] = 0.76536686473018;
                p[1] = 1.84775906502257;
                
                b0[0] = (oc * oc / (4 + 2 * p[0] * oc + oc * oc));
                b0[1] = (2 * b0[0]);
                b0[2] = b0[0];
                a0[0] = 1;
                a0[1] = (2 * (oc * oc - 4) / (4 + 2 * p[0] * oc + oc * oc));
                a0[2] = ((4 - 2 * p[0] * oc + oc * oc) / (4 + 2 * p[0] * oc + oc * oc));
                
                b1[0] = (oc * oc / (4 + 2 * p[1] * oc + oc * oc));
                b1[1] = (2 * b1[0]);
                b1[2] = b1[0];
                a1[0] = 1;
                a1[1] = (2 * (oc * oc - 4) / (4 + 2 * p[1] * oc + oc * oc));
                a1[2] = ((4 - 2 * p[1] * oc + oc * oc) / (4 + 2 * p[1] * oc + oc * oc));
                
                b2[0] = b0[0];
                b2[1] = b0[1];
                b2[2] = b0[2];
                a2[0] = a0[0];
                a2[1] = a0[1];
                a2[2] = a0[2];
                
                b3[0] = b1[0];
                b3[1] = b1[1];
                b3[2] = b1[2];
                a3[0] = a1[0];
                a3[1] = a1[1];
                a3[2] = a1[2];
                
//                one_0 = new double[line_xover_length];
//                one_1 = new double[line_xover_length];
//                one_2 = new double[line_xover_length];
//                one_3 = new double[line_xover_length];
//
//                mk(f, a0, b0,  one_0, line_xover_length, false);
//                mk(f, a1, b1,  one_1, line_xover_length, false);
//                mk(f, a2, b2,  one_2, line_xover_length, false);
//                mk(f, a3, b3,  one_3, line_xover_length, false);
                
                one_0 = createArray(line_xover_length);
                one_1 = createArray(line_xover_length);
                one_2 = createArray(line_xover_length);
                one_3 = createArray(line_xover_length);
                mk(f, a0,b0,one_0,line_xover_length,false);
                mk(f,a1,b1,one_1,line_xover_length,false);
                mk(f,a2,b2,one_2,line_xover_length,false);
                mk(f,a3,b3,one_3,line_xover_length,false);

                
                for (int i=0;i<line_xover_length;i++)
                {
                    line_xover[i]=(one_0[i]+one_1[i]+one_2[i]+one_3[i]);
                }
                
                
                if(f==FREQUENCY_MAX)
                {
                    for (int i = 0; i < line_xover_length; i++)
                    {
                        // line_xover[i] =((line_xover[i] * pow10))/ pow10;
                        line_xover[i] =0;
                    }
                }
                
            }
                break;
                
                
            default:
                break;
        }
    }else
    {
        switch(oct_type)
        {
                
                
                
            case 0://BW-06
            {
                
                
                
                
                
                p[0] = 1;
                
                b0[0] = (oc / (c1 + p[0] * oc));
                b0[1] = (-b0[0]);
                b0[2] = 0;
                a0[0] = 1;
                a0[1] = (-(p[0] * oc - c1) / (c1 + p[0] * oc));
                a0[2] = 0;
//                one_0 = new double[line_xover_length];
//                mk(f, a0, b0, one_0,line_xover_length,false);
                one_0 = createArray(line_xover_length);
                mk(f, a0,b0,one_0,line_xover_length,false);

                for (int i=0;i<line_xover_length;i++)
                {
                    line_xover[i]=one_0[i];
                }
                
                
                if(f==FREQUENCY_MIN)
                {
                    for (int i = 0; i < line_xover_length; i++)
                    {
                        // line_xover[i] =((line_xover[i] * pow10))/ pow10;
                        line_xover[i] =0;
                    }
                }
                
                
                
            }
                break;
            case 1://BW-12
            {
                
                
                
                
                p[0] = 1.41421356237309;
                
                b0[0] = (oc * oc / (c1 * c1 + c1 * p[0] * oc + oc * oc));
                b0[1] = (-2 * b0[0]);
                b0[2] = b0[0];
                a0[0] = 1;
                a0[1] = (-2 * (oc * oc - c1 * c1) / (c1 * c1 + c1 * p[0] * oc + oc * oc));
                a0[2] = ((c1 * c1 - c1 * p[0] * oc + oc * oc) / (c1 * c1 + c1 * p[0] * oc + oc * oc));
//                one_0 = new double[line_xover_length];
//                mk(f, a0, b0,one_0,line_xover_length, false);
                one_0 = createArray(line_xover_length);
                mk(f, a0,b0,one_0,line_xover_length,false);
                
                for (int i=0;i<line_xover_length;i++)
                {
                    line_xover[i]=one_0[i];
                }
                
                if(f==FREQUENCY_MIN)
                {
                    for (int i = 0; i < line_xover_length; i++)
                    {
                        // line_xover[i] =((line_xover[i] * pow10))/ pow10;
                        line_xover[i] =0;
                    }
                }
                
                
            }
                break;
            case 2://BW-18
            {
                p[0] = 1;
                p[1] = 1;
                
                b0[0] = (oc * oc / (c1 * c1 + c1 * p[0] * oc + oc * oc));
                b0[1] = (-2 * b0[0]);
                b0[2] = b0[0];
                a0[0] = 1;
                a0[1] = (-2 * (oc * oc - c1 * c1) / (c1 * c1 + c1 * p[0] * oc + oc * oc));
                a0[2] = ((c1 * c1 - c1 * p[0] * oc + oc * oc) / (c1 * c1 + c1 * p[0] * oc + oc * oc));
                
                b1[0] = (p[1] * oc / (c1 + p[1] * oc));
                
                b1[1] = (-b1[0]);
                b1[2] = 0;
                a1[0] = 1;
                a1[1] = (-(p[1] * oc - c1) / (c1 + p[1] * oc));
                a1[2] = 0;
                
//                one_0 = new double[line_xover_length];
//                one_1 = new double[line_xover_length];
//
//                mk(f, a0, b0, one_0,line_xover_length ,false);
//                mk(f, a1, b1, one_1,line_xover_length ,false);
                one_0 = createArray(line_xover_length);
                one_1 = createArray(line_xover_length);
                mk(f, a0,b0,one_0,line_xover_length,false);
                mk(f,a1,b1,one_1,line_xover_length,false);
                
                for (int i = 0; i < line_xover_length; i++)
                {
                    line_xover[i] = (one_0[i] + one_1[i]);
                }
                if(f==FREQUENCY_MIN)
                {
                    for (int i = 0; i < line_xover_length; i++)
                    {
                        // line_xover[i] =((line_xover[i] * pow10))/ pow10;
                        line_xover[i] =0;
                    }
                }
                
            }
                break;
            case 3://BW-24
            {
                p[0] = 0.76536686473018;
                p[1] = 1.84775906502257;
                
                b0[0] = (oc * oc / (c1 * c1 + c1 * p[0] * oc + oc * oc));
                b0[1] = (-2 * b0[0]);
                b0[2] = b0[0];
                a0[0] = 1;
                a0[1] = (-2 * (oc * oc - c1 * c1) / (c1 * c1 + c1 * p[0] * oc + oc * oc));
                a0[2] = ((c1 * c1 - c1 * p[0] * oc + oc * oc) / (c1 * c1 + c1 * p[0] * oc + oc * oc));
                
                b1[0] = (oc * oc / (c1 * c1 + c1 * p[1] * oc + oc * oc));
                b1[1] = (-2 * b1[0]);
                b1[2] = b1[0];
                a1[0] = 1;
                a1[1] = (-2 * (oc * oc - c1 * c1) / (c1 * c1 + c1 * p[1] * oc + oc * oc));
                a1[2] = ((c1 * c1 - c1 * p[1] * oc + oc * oc) / (c1 * c1 + c1 * p[1] * oc + oc * oc));
                
//                one_0 = new double[line_xover_length];
//                one_1 = new double[line_xover_length];
//                mk(f, a0, b0,one_0,line_xover_length, false);
//                mk(f, a1, b1,one_1,line_xover_length, false);
                one_0 = createArray(line_xover_length);
                one_1 = createArray(line_xover_length);
                mk(f, a0,b0,one_0,line_xover_length,false);
                mk(f,a1,b1,one_1,line_xover_length,false);

                
                for (int i=0;i<line_xover_length;i++)
                {
                    line_xover[i]=(one_0[i]+one_1[i]);
                }
                
                if(f==FREQUENCY_MIN)
                {
                    for (int i = 0; i < line_xover_length; i++)
                    {
                        // line_xover[i] =((line_xover[i] * pow10))/ pow10;
                        line_xover[i] =0;
                    }
                }
                
                
            }
                break;
            case 4://BW-36
            {
                p[0] = 0.51763809020504;
                p[1] = 1.41421356237309;
                p[2] = 1.93185165257814;
                
                b0[0] = (oc * oc / (c1 * c1 + c1 * p[0] * oc + oc * oc));
                b0[1] = (-2 * b0[0]);
                b0[2] = b0[0];
                a0[0] = 1;
                a0[1] = (-2 * (oc * oc - c1 * c1) / (c1 * c1 + c1 * p[0] * oc + oc * oc));
                a0[2] = ((c1 * c1 - c1 * p[0] * oc + oc * oc) / (c1 * c1 + c1 * p[0] * oc + oc * oc));
                
                b1[0] = (oc * oc / (c1 * c1 + c1 * p[1] * oc + oc * oc));
                b1[1] = (-2 * b1[0]);
                b1[2] = b1[0];
                a1[0] = 1;
                a1[1] = (-2 * (oc * oc - c1 * c1) / (c1 * c1 + c1 * p[1] * oc + oc * oc));
                a1[2] = ((c1 * c1 - c1 * p[1] * oc + oc * oc) / (c1 * c1 + c1 * p[1] * oc + oc * oc));
                
                b2[0] = (oc * oc / (c1 * c1 + c1 * p[2] * oc + oc * oc));
                b2[1] = (-2 * b2[0]);
                b2[2] = b2[0];
                a2[0] = 1;
                a2[1] = (-2 * (oc * oc - c1 * c1) / (c1 * c1 + c1 * p[2] * oc + oc * oc));
                a2[2] = ((c1 * c1 - c1 * p[2] * oc + oc * oc) / (c1 * c1 + c1 * p[2] * oc + oc * oc));
                
//                one_0 = new double[line_xover_length];
//                one_1 = new double[line_xover_length];
//                one_2 = new double[line_xover_length];
//                mk(f, a0, b0,one_0,line_xover_length, false);
//                mk(f, a1, b1,one_1,line_xover_length, false);
//                mk(f, a2, b2,one_2,line_xover_length, false);
                one_0 = createArray(line_xover_length);
                one_1 = createArray(line_xover_length);
                one_2 = createArray(line_xover_length);
                mk(f, a0,b0,one_0,line_xover_length,false);
                mk(f,a1,b1,one_1,line_xover_length,false);
                mk(f,a2,b2,one_2,line_xover_length,false);
                
                for (int i=0;i<line_xover_length;i++)
                {
                    line_xover[i]=(one_0[i]+one_1[i]+one_2[i]);
                }
                
                if(f==FREQUENCY_MIN)
                {
                    for (int i = 0; i < line_xover_length; i++)
                    {
                        // line_xover[i] =((line_xover[i] * pow10))/ pow10;
                        line_xover[i] =0;
                    }
                }
                
                
            }break;
            case 5://BW-48
            {
                p[0] = 0.39018064403226;
                p[1] = 1.11114046603920;
                p[2] = 1.66293922460509;
                p[3] = 1.96157056080646;
                
                b0[0] = (oc * oc / (c1 * c1 + c1 * p[0] * oc + oc * oc));
                b0[1] = (-2 * b0[0]);
                b0[2] = b0[0];
                a0[0] = 1;
                a0[1] = (-2 * (oc * oc - c1 * c1) / (c1 * c1 + c1 * p[0] * oc + oc * oc));
                a0[2] = ((c1 * c1 - c1 * p[0] * oc + oc * oc) / (c1 * c1 + c1 * p[0] * oc + oc * oc));
                
                b1[0] = (oc * oc / (c1 * c1 + c1 * p[1] * oc + oc * oc));
                b1[1] = (-2 * b1[0]);
                b1[2] = b1[0];
                a1[0] = 1;
                a1[1] = (-2 * (oc * oc - c1 * c1) / (c1 * c1 + c1 * p[1] * oc + oc * oc));
                a1[2] = ((c1 * c1 - c1 * p[1] * oc + oc * oc) / (c1 * c1 + c1 * p[1] * oc + oc * oc));
                
                b2[0] = (oc * oc / (c1 * c1 + c1 * p[2] * oc + oc * oc));
                b2[1] = (-2 * b2[0]);
                b2[2] = b2[0];
                a2[0] = 1;
                a2[1] = (-2 * (oc * oc - c1 * c1) / (c1 * c1 + c1 * p[2] * oc + oc * oc));
                a2[2] = ((c1 * c1 - c1 * p[2] * oc + oc * oc) / (c1 * c1 + c1 * p[2] * oc + oc * oc));
                
                b3[0] = (oc * oc / (c1 * c1 + c1 * p[3] * oc + oc * oc));
                b3[1] = (-2 * b3[0]);
                b3[2] = b3[0];
                a3[0] = 1;
                a3[1] = (-2 * (oc * oc - c1 * c1) / (c1 * c1 + c1 * p[3] * oc + oc * oc));
                a3[2] = ((c1 * c1 - c1 * p[3] * oc + oc * oc) / (c1 * c1 + c1 * p[3] * oc + oc * oc));
                
//                one_0 = new double[line_xover_length];
//                one_1 = new double[line_xover_length];
//                one_2 = new double[line_xover_length];
//                one_3 = new double[line_xover_length];
//                mk(f, a0, b0,one_0,line_xover_length, false);
//                mk(f, a1, b1,one_1,line_xover_length, false);
//                mk(f, a2, b2,one_2,line_xover_length, false);
//                mk(f, a3, b3,one_3,line_xover_length, false);
                one_0 = createArray(line_xover_length);
                one_1 = createArray(line_xover_length);
                one_2 = createArray(line_xover_length);
                one_3 = createArray(line_xover_length);
                mk(f, a0,b0,one_0,line_xover_length,false);
                mk(f,a1,b1,one_1,line_xover_length,false);
                mk(f,a2,b2,one_2,line_xover_length,false);
                mk(f,a3,b3,one_3,line_xover_length,false);
                
                
                for (int i=0;i<line_xover_length;i++)
                {
                    line_xover[i]=(one_0[i]+one_1[i]+one_2[i]+one_3[i]);
                }
                
                if(f==FREQUENCY_MIN)
                {
                    for (int i = 0; i < line_xover_length; i++)
                    {
                        // line_xover[i] =((line_xover[i] * pow10))/ pow10;
                        line_xover[i] =0;
                    }
                }
                
            }break;
            case 6://BS-12
            {
                p[0] = 1.73205080756888;
                
                b0[0] = (oc * oc / (c1 * c1 + c1 * p[0] * oc + oc * oc));
                b0[1] = (-2 * b0[0]);
                b0[2] = b0[0];
                a0[0] = 1;
                a0[1] = (-2 * (oc * oc - c1 * c1) / (c1 * c1 + c1 * p[0] * oc + oc * oc));
                a0[2] = ((c1 * c1 - c1 * p[0] * oc + oc * oc) / (c1 * c1 + c1 * p[0] * oc + oc * oc));
                
//                one_0 = new double[line_xover_length];
//                mk(f, a0, b0,one_0,line_xover_length, false);
                one_0 = createArray(line_xover_length);
                mk(f, a0,b0,one_0,line_xover_length,false);

                
                for (int i=0;i<line_xover_length;i++)
                {
                    line_xover[i]=one_0[i];
                }
                
                if(f==FREQUENCY_MIN)
                {
                    for (int i = 0; i < line_xover_length; i++)
                    {
                        // line_xover[i] =((line_xover[i] * pow10))/ pow10;
                        line_xover[i] =0;
                    }
                }
                
                
            }break;
            case 7://BS-18
            {
                p[0] = 1.49128077169616;
                p[1] = 0.94160002653321;
                
                b0[0] = (oc * oc / (c1 * c1 + c1 * p[0] * oc + oc * oc));
                b0[1] = (-2 * b0[0]);
                b0[2] = b0[0];
                a0[0] = 1;
                a0[1] = (-2 * (oc * oc - c1 * c1) / (c1 * c1 + c1 * p[0] * oc + oc * oc));
                a0[2] = ((c1 * c1 - c1 * p[0] * oc + oc * oc) / (c1 * c1 + c1 * p[0] * oc + oc * oc));
                
                b1[0] = (p[1] * oc / (c1 + p[1] * oc));
                b1[1] = (-b1[0]);
                b1[2] = 0;
                a1[0] = 1;
                a1[1] = (-(p[1] * oc - c1) / (c1 + p[1] * oc));
                a1[2] = 0;
                
//                one_0 = new double[line_xover_length];
//                one_1 = new double[line_xover_length];
//
//                mk(f, a0, b0, one_0,line_xover_length ,false);
//                mk(f, a1, b1, one_1,line_xover_length ,false);
                one_0 = createArray(line_xover_length);
                one_1 = createArray(line_xover_length);
                mk(f, a0,b0,one_0,line_xover_length,false);
                mk(f,a1,b1,one_1,line_xover_length,false);

                
                for (int i = 0; i < line_xover_length; i++)
                {
                    line_xover[i] = ((one_0[i] + one_1[i]));
                }
                
                if(f==FREQUENCY_MIN)
                {
                    for (int i = 0; i < line_xover_length; i++)
                    {
                        // line_xover[i] =((line_xover[i] * pow10))/ pow10;
                        line_xover[i] =0;
                    }
                }
                
            }break;
            case 8://BS-24
            {
                p[0] = 1.31442234334377;
                p[1] = 1.80951759357649;
                
                b0[0] = (oc * oc / (c1 * c1 + c1 * p[0] * oc + oc * oc));
                b0[1] = (-2 * b0[0]);
                b0[2] = b0[0];
                a0[0] = 1;
                a0[1] = (-2 * (oc * oc - c1 * c1) / (c1 * c1 + c1 * p[0] * oc + oc * oc));
                a0[2] = ((c1 * c1 - c1 * p[0] * oc + oc * oc) / (c1 * c1 + c1 * p[0] * oc + oc * oc));
                
                b1[0] = (oc * oc / (c1 * c1 + c1 * p[1] * oc + oc * oc));
                b1[1] = (-2 * b1[0]);
                b1[2] = b1[0];
                a1[0] = 1;
                a1[1] = (-2 * (oc * oc - c1 * c1) / (c1 * c1 + c1 * p[1] * oc + oc * oc));
                a1[2] = ((c1 * c1 - c1 * p[1] * oc + oc * oc) / (c1 * c1 + c1 * p[1] * oc + oc * oc));
                
//                one_0 = new double[line_xover_length];
//                one_1 = new double[line_xover_length];
//
//                mk(f, a0, b0, one_0,line_xover_length ,false);
//                mk(f, a1, b1, one_1,line_xover_length ,false);
                one_0 = createArray(line_xover_length);
                one_1 = createArray(line_xover_length);
                mk(f, a0,b0,one_0,line_xover_length,false);
                mk(f,a1,b1,one_1,line_xover_length,false);

                
                for (int i = 0; i < line_xover_length; i++)
                {
                    line_xover[i] = (one_0[i] + one_1[i]);
                }
                
                if(f==FREQUENCY_MIN)
                {
                    for (int i = 0; i < line_xover_length; i++)
                    {
                        // line_xover[i] =((line_xover[i] * pow10))/ pow10;
                        line_xover[i] =0;
                    }
                }
                
                
            }break;
                
            case 9://BS-36
            {
                p[0] = 1.81878136609445;
                p[1] = 1.59930837166566;
                p[2] = 1.07710536333862;
                
                b0[0] = (oc * oc / (c1 * c1 + c1 * p[0] * oc + oc * oc));
                b0[1] = (-2 * b0[0]);
                b0[2] = b0[0];
                a0[0] = 1;
                a0[1] = (-2 * (oc * oc - c1 * c1) / (c1 * c1 + c1 * p[0] * oc + oc * oc));
                a0[2] = ((c1 * c1 - c1 * p[0] * oc + oc * oc) / (c1 * c1 + c1 * p[0] * oc + oc * oc));
                
                b1[0] = (oc * oc / (c1 * c1 + c1 * p[1] * oc + oc * oc));
                b1[1] = (-2 * b1[0]);
                b1[2] = b1[0];
                a1[0] = 1;
                a1[1] = (-2 * (oc * oc - c1 * c1) / (c1 * c1 + c1 * p[1] * oc + oc * oc));
                a1[2] = ((c1 * c1 - c1 * p[1] * oc + oc * oc) / (c1 * c1 + c1 * p[1] * oc + oc * oc));
                
                b2[0] = (oc * oc / (c1 * c1 + c1 * p[2] * oc + oc * oc));
                b2[1] = (-2 * b2[0]);
                b2[2] = b2[0];
                a2[0] = 1;
                a2[1] = (-2 * (oc * oc - c1 * c1) / (c1 * c1 + c1 * p[2] * oc + oc * oc));
                a2[2] = ((c1 * c1 - c1 * p[2] * oc + oc * oc) / (c1 * c1 + c1 * p[2] * oc + oc * oc));
                
//                one_0 = new double[line_xover_length];
//                one_1 = new double[line_xover_length];
//                one_2 = new double[line_xover_length];
//                mk(f, a0, b0, one_0,line_xover_length ,false);
//                mk(f, a1, b1, one_1,line_xover_length ,false);
//                mk(f, a2, b2, one_2,line_xover_length ,false);
                one_0 = createArray(line_xover_length);
                one_1 = createArray(line_xover_length);
                one_2 = createArray(line_xover_length);
                mk(f, a0,b0,one_0,line_xover_length,false);
                mk(f,a1,b1,one_1,line_xover_length,false);
                mk(f,a2,b2,one_2,line_xover_length,false);
                
                for (int i = 0; i < line_xover_length; i++)
                {
                    line_xover[i] = (one_0[i] + one_1[i]+one_2[i]);
                }
                
                if(f==FREQUENCY_MIN)
                {
                    for (int i = 0; i < line_xover_length; i++)
                    {
                        // line_xover[i] =((line_xover[i] * pow10))/ pow10;
                        line_xover[i] =0;
                    }
                }
            }
                break;
            case 10://BS-48
            {
                p[0] = 1.81936630933058;
                p[1] = 1.69465016047187;
                p[2] = 1.42227636169708;
                p[3] = 0.92434808250642;
                
                b0[0] = (oc * oc / (c1 * c1 + c1 * p[0] * oc + oc * oc));
                b0[1] = (-2 * b0[0]);
                b0[2] = b0[0];
                a0[0] = 1;
                a0[1] = (-2 * (oc * oc - c1 * c1) / (c1 * c1 + c1 * p[0] * oc + oc * oc));
                a0[2] = ((c1 * c1 - c1 * p[0] * oc + oc * oc) / (c1 * c1 + c1 * p[0] * oc + oc * oc));
                
                b1[0] = (oc * oc / (c1 * c1 + c1 * p[1] * oc + oc * oc));
                b1[1] = (-2 * b1[0]);
                b1[2] = b1[0];
                a1[0] = 1;
                a1[1] = (-2 * (oc * oc - c1 * c1) / (c1 * c1 + c1 * p[1] * oc + oc * oc));
                a1[2] = ((c1 * c1 - c1 * p[1] * oc + oc * oc) / (c1 * c1 + c1 * p[1] * oc + oc * oc));
                
                b2[0] = (oc * oc / (c1 * c1 + c1 * p[2] * oc + oc * oc));
                b2[1] = (-2 * b2[0]);
                b2[2] = b2[0];
                a2[0] = 1;
                a2[1] = (-2 * (oc * oc - c1 * c1) / (c1 * c1 + c1 * p[2] * oc + oc * oc));
                a2[2] = ((c1 * c1 - c1 * p[2] * oc + oc * oc) / (c1 * c1 + c1 * p[2] * oc + oc * oc));
                
                b3[0] = (oc * oc / (c1 * c1 + c1 * p[3] * oc + oc * oc));
                b3[1] = (-2 * b3[0]);
                b3[2] = b3[0];
                a3[0] = 1;
                a3[1] = (-2 * (oc * oc - c1 * c1) / (c1 * c1 + c1 * p[3] * oc + oc * oc));
                a3[2] = ((c1 * c1 - c1 * p[3] * oc + oc * oc) / (c1 * c1 + c1 * p[3] * oc + oc * oc));
                
//                one_0 = new double[line_xover_length];
//                one_1 = new double[line_xover_length];
//                one_2 = new double[line_xover_length];
//                one_3 = new double[line_xover_length];
//                mk(f, a0, b0, one_0,line_xover_length ,false);
//                mk(f, a1, b1, one_1,line_xover_length ,false);
//                mk(f, a2, b2, one_2,line_xover_length ,false);
//                mk(f, a3, b3, one_3,line_xover_length ,false);
                one_0 = createArray(line_xover_length);
                one_1 = createArray(line_xover_length);
                one_2 = createArray(line_xover_length);
                one_3 = createArray(line_xover_length);
                mk(f, a0,b0,one_0,line_xover_length,false);
                mk(f,a1,b1,one_1,line_xover_length,false);
                mk(f,a2,b2,one_2,line_xover_length,false);
                 mk(f,a3,b3,one_3,line_xover_length,false);
                
                for (int i = 0; i < line_xover_length; i++)
                {
                    line_xover[i] = ((one_0[i] + one_1[i]+one_2[i]+one_3[i]));
                }
                
                if(f==FREQUENCY_MIN)
                {
                    for (int i = 0; i < line_xover_length; i++)
                    {
                        // line_xover[i] =((line_xover[i] * pow10))/ pow10;
                        line_xover[i] =0;
                    }
                }
            }
                break;
            case 11://LK-12
            {
                b0[0] = (oc / (c1 + oc));
                b0[1] = (-b0[0]);
                b0[2] = 0;
                a0[0] = 1;
                a0[1] = (-(oc - c1) / (c1 + oc));
                a0[2] = 0;
                
                b1[0] = b0[0];
                b1[1] = b0[1];
                b1[2] = b0[2];
                a1[0] = a0[0];
                a1[1] = a0[1];
                a1[2] = a0[2];
                
//                one_0 = new double[line_xover_length];
//                one_1 = new double[line_xover_length];
//                mk(f, a0, b0,one_0,line_xover_length, false);
//                mk(f, a1, b1,one_1,line_xover_length, false);
                one_0 = createArray(line_xover_length);
                one_1 = createArray(line_xover_length);
                mk(f, a0,b0,one_0,line_xover_length,false);
                mk(f,a1,b1,one_1,line_xover_length,false);

                
                for (int i=0;i<line_xover_length;i++)
                {
                    line_xover[i]=(one_0[i]+one_1[i]);
                }
                
                if(f==FREQUENCY_MIN)
                {
                    for (int i = 0; i < line_xover_length; i++)
                    {
                        // line_xover[i] =((line_xover[i] * pow10))/ pow10;
                        line_xover[i] =0;
                    }
                }
                
            }
                break;
            case 12: //LK-24
            {
                p[0] = 1.41421356237309;
                
                b0[0] = (oc * oc / (c1 * c1 + c1 * p[0] * oc + oc * oc));
                b0[1] = (-2 * b0[0]);
                b0[2] = b0[0];
                a0[0] = 1;
                a0[1] = (-2 * (oc * oc - c1 * c1) / (c1 * c1 + c1 * p[0] * oc + oc * oc));
                a0[2] = ((c1 * c1 - c1 * p[0] * oc + oc * oc) / (c1 * c1 + c1 * p[0] * oc + oc * oc));
                
                b1[0] = b0[0];
                b1[1] = b0[1];
                b1[2] = b0[2];
                a1[0] = a0[0];
                a1[1] = a0[1];
                a1[2] = a0[2];
                
//                one_0 = new double[line_xover_length];
//                one_1 = new double[line_xover_length];
//                mk(f, a0, b0,one_0,line_xover_length, false);
//                mk(f, a1, b1,one_1,line_xover_length, false);
                one_0 = createArray(line_xover_length);
                one_1 = createArray(line_xover_length);
                mk(f, a0,b0,one_0,line_xover_length,false);
                mk(f,a1,b1,one_1,line_xover_length,false);

                
                for (int i=0;i<line_xover_length;i++)
                {
                    line_xover[i]=(one_0[i]+one_1[i]);
                }
                
                if(f==FREQUENCY_MIN)
                {
                    for (int i = 0; i < line_xover_length; i++)
                    {
                        // line_xover[i] =((line_xover[i] * pow10))/ pow10;
                        line_xover[i] =0;
                    }
                }
                
            }
                break;
            case 13://LK-36
            {
                p[0] = 0.76536686473018;
                p[1] = 1.84775906502257;
                p[2] = 1.41421356237309;
                
                b0[0] = (oc * oc / (c1 * c1 + c1 * p[0] * oc + oc * oc));
                b0[1] = (-2 * b0[0]);
                b0[2] = b0[0];
                a0[0] = 1;
                a0[1] = (-2 * (oc * oc - c1 * c1) / (c1 * c1 + c1 * p[0] * oc + oc * oc));
                a0[2] = ((c1 * c1 - c1 * p[0] * oc + oc * oc) / (c1 * c1 + c1 * p[0] * oc + oc * oc));
                
                b1[0] = (oc * oc / (c1 * c1 + c1 * p[1] * oc + oc * oc));
                b1[1] = (-2 * b1[0]);
                b1[2] = b1[0];
                a1[0] = 1;
                a1[1] = (-2 * (oc * oc - c1 * c1) / (c1 * c1 + c1 * p[1] * oc + oc * oc));
                a1[2] = ((c1 * c1 - c1 * p[1] * oc + oc * oc) / (c1 * c1 + c1 * p[1] * oc + oc * oc));
                
                b2[0] = (oc * oc / (c1 * c1 + c1 * p[2] * oc + oc * oc));
                b2[1] = (-2 * b2[0]);
                b2[2] = b2[0];
                a2[0] = 1;
                a2[1] = (-2 * (oc * oc - c1 * c1) / (c1 * c1 + c1 * p[2] * oc + oc * oc));
                a2[2] = ((c1 * c1 - c1 * p[2] * oc + oc * oc) / (c1 * c1 + c1 * p[2] * oc + oc * oc));
                
//                one_0 = new double[line_xover_length];
//                one_1 = new double[line_xover_length];
//                one_2 = new double[line_xover_length];
//                mk(f, a0, b0,one_0,line_xover_length, false);
//                mk(f, a1, b1,one_1,line_xover_length, false);
//                mk(f, a2, b2,one_2,line_xover_length, false);
                one_0 = createArray(line_xover_length);
                one_1 = createArray(line_xover_length);
                one_2 = createArray(line_xover_length);
                mk(f, a0,b0,one_0,line_xover_length,false);
                mk(f,a1,b1,one_1,line_xover_length,false);
                mk(f,a2,b2,one_2,line_xover_length,false);
                
                for (int i=0;i<line_xover_length;i++)
                {
                    line_xover[i]=(one_0[i]+one_1[i]+one_2[i]);
                }
                
                if(f==FREQUENCY_MIN)
                {
                    for (int i = 0; i < line_xover_length; i++)
                    {
                        // line_xover[i] =((line_xover[i] * pow10))/ pow10;
                        line_xover[i] =0;
                    }
                }
                
            }
                break;
            case 14://LK-48
            {
                p[0] = 0.76536686473018;
                p[1] = 1.84775906502257;
                
                b0[0] = (oc * oc / (c1 * c1 + c1 * p[0] * oc + oc * oc));
                b0[1] = (-2 * b0[0]);
                b0[2] = b0[0];
                a0[0] = 1;
                a0[1] = (-2 * (oc * oc - c1 * c1) / (c1 * c1 + c1 * p[0] * oc + oc * oc));
                a0[2] = ((c1 * c1 - c1 * p[0] * oc + oc * oc) / (c1 * c1 + c1 * p[0] * oc + oc * oc));
                
                b1[0] = (oc * oc / (c1 * c1 + c1 * p[1] * oc + oc * oc));
                b1[1] = (-2 * b1[0]);
                b1[2] = b1[0];
                a1[0] = 1;
                a1[1] = (-2 * (oc * oc - c1 * c1) / (c1 * c1 + c1 * p[1] * oc + oc * oc));
                a1[2] = ((c1 * c1 - c1 * p[1] * oc + oc * oc) / (c1 * c1 + c1 * p[1] * oc + oc * oc));
                
                b2[0] = b0[0];
                b2[1] = b0[1];
                b2[2] = b0[2];
                a2[0] = a0[0];
                a2[1] = a0[1];
                a2[2] = a0[2];
                
                b3[0] = b1[0];
                b3[1] = b1[1];
                b3[2] = b1[2];
                a3[0] = a1[0];
                a3[1] = a1[1];
                a3[2] = a1[2];
                
                
//                one_0 = new double[line_xover_length];
//                one_1 = new double[line_xover_length];
//                one_2 = new double[line_xover_length];
//                one_3 = new double[line_xover_length];
//                mk(f, a0, b0,one_0,line_xover_length, false);
//                mk(f, a1, b1,one_1,line_xover_length, false);
//                mk(f, a2, b2,one_2,line_xover_length, false);
//                mk(f, a3, b3,one_3,line_xover_length, false);
                one_0 = createArray(line_xover_length);
                one_1 = createArray(line_xover_length);
                one_2 = createArray(line_xover_length);
                one_3 = createArray(line_xover_length);
                mk(f, a0,b0,one_0,line_xover_length,false);
                mk(f,a1,b1,one_1,line_xover_length,false);
                mk(f,a2,b2,one_2,line_xover_length,false);
                mk(f,a3,b3,one_3,line_xover_length,false);
                
                
                for (int i=0;i<line_xover_length;i++)
                {
                    line_xover[i]=(one_0[i]+one_1[i]+one_2[i]+one_3[i]);
                }
                
                if(f==FREQUENCY_MIN)
                {
                    for (int i = 0; i < line_xover_length; i++)
                    {
                        // line_xover[i] =((line_xover[i] * pow10))/ pow10;
                        line_xover[i] =0;
                    }
                }
                
            }
                break;
                
                
            default:
                break;
        }
        
        
    }
    
//    delete  []p ;
//    delete []a0 ;delete []b0;
//    delete []a1,delete [] b1 ;
//    delete []a2 ,delete [] b2 ;
//    delete []a3 ,delete [] b3 ;
    
//    if(one_0!=NULL)
//        delete []one_0;
//
//    if(one_1!=NULL)
//        delete []one_1;
//    if(one_2!=NULL)
//        delete []one_2;
//    if(one_3!=NULL)
//        delete []one_3;
}

static double int2fc2(int var0,int var1,int var2)
{
    double var3 = var2.toDouble();
    double var5 = var0.toDouble();
    return pow(10.0, (var3 - var1) / (var5 - var1) * (log10(22000.0) - log10(20.0)) + log10(20.0)) as double;
}

static void double2float(double var0,int var1,List<double> var2,int var3,List<double> var4)
{
    try{
      for (int var5 = 0; var5 < var2.length; ++var5) {
      var4[var5 * 4] = (var3 + var5).toDouble();
      var4[var5 * 4 + 1] = (var2[var5] *  var0 + var1);
    }
    
    for (var1 = 0; var1 < var2.length - 1; ++var1) {
        var4[var1 * 4 + 2] = var4[(var1 + 1) * 4];
        var4[var1 * 4 + 3] = var4[(var1 + 1) * 4 + 1];
    }
    
    var4[var1 * 4 + 2] = (var4[var1 * 4] + 1.0);
    var4[var1 * 4 + 3] = var4[var1 * 4 + 1];
    } catch(e){

    }
}

static double bouldvalue(int var0,int var1,int var2)
{
    return min(var0.toDouble(), max(var1.toDouble(), var2.toDouble()));
}
}